package com.sec.android.app.myfiles.feature;

import android.content.Context;
import android.provider.Settings;
import android.view.View;
import android.widget.PopupWindow;

import com.sec.android.app.myfiles.feature.Hover.HoverImp;
import com.sec.android.app.myfiles.fragment.AbsMyFilesFragment;
import com.sec.android.app.myfiles.module.abstraction.FileRecord;

public class HoverMgr {
    private static HoverMgr sInstance;
    private Context mContext;

    private PopupWindow mShownView = null;

    public static HoverMgr getInstance(Context context) {
        if (sInstance == null) {
            sInstance = new HoverMgr(context);
        }

        return sInstance;
    }

    private HoverMgr(Context context) {
        mContext = context.getApplicationContext();
    }

    public boolean isEnablePenHovering(Context context) {
        boolean bRet = false;
        return bRet;
    }

    public void setHoverListener(View view, FileRecord record, AbsMyFilesFragment fragment, Context context) {
        if (isEnablePenHovering(mContext)) {
            HoverImp hoverImp = new HoverImp(record, fragment, context);
            hoverImp.setHoverPopupListener(view);
        }

    }

    public static boolean isSupportStorage(FileRecord record) {
        boolean bRet = true;
        switch (record.getStorageType()) {
            case Cloud:
                /* FALL THROUGH */
            case Trash:
                bRet = false;
                break;
            case Compress:
                bRet = false;
                break;
        }
        return bRet;
    }

    public void setShownHoverView(PopupWindow view) {
        mShownView = view;
    }

    public void dismissHoverView() {
        if (mShownView != null) {
            if (mShownView.isShowing()) {
                mShownView.dismiss();
            }
            mShownView = null;
        }
    }

    public boolean isHoverExist() {
        if (mShownView != null) {
            return true;
        }

        return false;
    }

}
